Hello and welcome to this lecture in this lecture.
We all be creating the functionality for our app using javascript.
This is going to be a two part lecture series.
So this part one we'll start and we'll finish off in part two.
So this is my javascript file.
The way this letter is going to work I am going to write the code added code on and then explain it.
So to start with I'm going to create a variable that I will call questions and his sound is variable.
He's going to have one set variable two equals two and three sound inside that area.
We also have objects that will include the questions for the quiz.
The choices you have to make and then the correct answer.
So we'll go from the law of use up inside variable and set that variable to equal to an array and their
array with contain objects are also array within that object as well right.
I have added some code on a chunk of code so land one here have created a variable called questions.
Okay and I've said that to you.
So are narey So does the beginning.
He fires crews down and the hairy end on line.
Fifty three here.
So this is the clues in Harry.
And it's said that Harry.
You've also got objects so where you see curly braces.
You know that you're looking at an object where you see a square brackets.
Know that you are looking at an Harry saw inside this Harry and the object.
We've got the question.
So this is a question that the quiz will ask.
Then this.
This is the natural question with an object you need to have a property and then obviously the value.
So the question would be the property.
And this question here this reply here will be the value.
So I'm asking a question and this is the question.
And there are online three here.
Got another object property or choices and the value is equal to an array.
So he said that a rate is where the answers will be.
So look in true that Arey the correct answer would be three and three.
When you are accessing the elements in an hour and the reason it is zero B's index So the first one
is known that is zero so this would be B B.
It is here.
The correct answer is 3 Well it would be 0 1 2 3 weeks lava.
So just remember that when your numbering in an hour is starts is zero B's index the first one is usually
0.
So I saw the format for this.
Here is the format for all the questions inside.
Yes I agree.
So all these are values of this variable called Question everything here belongs to this variable questions
saw.
The format is the same.
I ask a question which is the property value which is the actual question.
The choices are includes inside an array and then we use the index base to pick up correct answers.
The format is the same all through okay and thus the very last question.
So you don't have to use the same.
I have used baby names of fundaments where you could do something.
You are completely interested in if you don't if you don't want to follow use baby.
So just as long as a format is the same you should the quiz should work as well.
Alright.
But any parts of this you don't understand.
Please feel free to let me in a line 55 56 57 new variables I have added the first variable is called
here corrent question set the value set to zero the correct answer is the value set to zero variable
var is set to false.
So all of these variables are set to zero or false.
False is a bully and value.
Is this true.
If we say that the result is either one or the other so is that true or false.
So with these values given the variables at the moment I have saw more code here from line 59.
The way to a line 91.
Oh right.
Let me walk you to the code line 59 when wherever you see dollar.
I know that you are referencing a jig query library.
59 basically say it's documented Dort ready function what this function does.
It checks to make sure that the page is fully loaded before it executes the code.
Dr. Reddy is what checks to make sure that the page simply is fully loaded so that you decode is not
executed prematurely before DP is fully loaded and diphthong chant whatever happens was a pay use law
that is displayed within the function which is this calibrators here.
We start online 59 and ends online 91.
So let me run through the code with you line 16.
This play the current question what that is it will display the very first question.
Okay.
Then six to one dollar and then did this inside the perimeter.
This refers to the current element is referring to.
So you say this got fined imperance this is so it will look for the next squeeze message dot hide or
key.
So what that means is that it hides the other's body.
Pfizer the current one.
Right.
And then line 62 then use the next button is say lower.
And then it's passed in this.
What did this metter does using a DOD find a tool pick out the next question is in the next button.
Okay.
And you notice the ever tight a dot dot on methot here.
And this metod toke seem to permeate out and the click which is event function.
So when there is a click on the button it wall the click will be the event it'll trigger of this function
here which is the what happens between this calibrators And was this embrace this yes everything in
here will be triggered it was the next button is clicked.
So I've got an if statement online six three saying if the question marks be as clear to me that if
the quiz is not over then the value equals two dollar which is a good query import type radio button.
If the your but is checked and the value the value of the Reagan put in this check and the quiz is not
over.
And if the value is not on defined diva value was not known to do this good pick up the document.
Fine fine look for the message look for the text and then select the right answer which will prompt
you to select the right answer.
Line 6 is 7 again since 6 similar approach looks picks up the quiz and then uses it.
Not sure method to display the quiz.
If that is were then an STD meant there are two conditions for seeing if the acquis is not over do this.
But if the quiz is over do this find this document the dodge.
Find me in this fine method this quiz and then hide it.
The value is equal to questions and it passed in the current question and the answer is correct then
correct answer.
You know you add the correct answer lattman What that means.
If the current question plus blows means if this increase in the question is a current question is less
than the question length lenthall the question displayer the current question.
Else display the score.
Okay.
So again using the query library again.
If the documents are fine till next button is not.
Once in a good bisley what's the same if you click on the next button.
It should display the.
It should give you a prompt to play bequeaths again see if the quiz is over.
If the quiz is over quiz is all right.
Drew them as the game is over.
You can start again.
That's where else else statement here where if all that force false is it acquisitional that do this.
Click on the next Botting get to this question.
If not the case of the quizzes over race you can reset the quiz using this function.
Display the corner oquist John.
You can hide the score so just Kois hid in on to the quiz or the questions I've been answered.
So that is it.
We've got to stop here for this lecture cause he's gone a bit long.
So we started off by defining variable and setting in the questions.
The question choices be answers.
Okay.
And then we moved on.
These are all the questions okay.
And then we moved down to set three variables there.
We also have Blue Dog komenda read the method and thus the rest of it.
So that's it for this lecture war completed in part two.
Thanks for watching.
There's any aspects you do not understand.
Please feel free to let me know.
Bye for now.